import {permissionList}  from '@/config/PermissionConfig'
import { ref, onMounted, useTemplateRef } from 'vue';
import {storeToRefs} from 'pinia'
import {type R} from "@/types/R"
import {request} from "@/utils/Request"
import {ElMessage, ElMessageBox} from "element-plus"
import {type PageInfo} from "@/types/PageInfo"
import {randomId} from "@/utils/IdUtils"
import { useSouYinTaiStore } from './SouYinTaiStore';
import { useApplicationStore } from '@/pages/application/applicationStore'

export const useSouYinTaiHooks = function(){
    let souYinTaiStore = useSouYinTaiStore()
    let {
        caseSouYinDialog,
        caseSouYinAO,
    } = storeToRefs(souYinTaiStore)

    let applicationStore = useApplicationStore();
    let {isCollapse} = storeToRefs(applicationStore)

    // 打开现金收银台
    const willCaseSouYin = ()=>{
        caseSouYinDialog.value = true
    }
    const caseSouYinCancel = ()=>{
        caseSouYinDialog.value = false
    }
    const caseSouYinSave = async()=>{
        let r:R<any> = await request.post("/pay/caseSouYin", {
            money: caseSouYinAO.value.money
        })
        if(r.code == "success"){
            ElMessage.success("收银成功")
        }
        caseSouYinDialog.value = false
    }

    return {
        isCollapse, willCaseSouYin, caseSouYinDialog,
        caseSouYinAO, caseSouYinCancel, caseSouYinSave,
    }
}
